import React from 'react';
import { inject, observer } from 'mobx-react';
import { WeaTableEdit, WeaDialog, WeaTextarea, WeaBrowser, WeaCheckbox, WeaDatePicker, WeaFormItem, WeaSelect, WeaLocaleProvider } from 'ecCom';
import { Button } from 'antd';
import AddRemindStore from '../../stores/remindStore/AddRemindStore';
import AddRemindForm from './AddRemindForm';
import './../../style/index';
import './../../util/index';

const getLabel = WeaLocaleProvider.getLabel;
@observer
export default class AddRemind extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      value: '',
      startValue: new Date().setDate(1),
      endValue: new Date(),
      store: new AddRemindStore(),
    };
  }

  componentWillMount() {
    const { store } = this.state;
    const { doNew } = store;
    doNew(this);
  }
  // componentDidMount() {
  //     // if (window.weaCrm) {
  //     //     this.setState({ weaCrmLoaded: true});
  //     // } else {
  //         window.top.eventRegister.loadModule('f_crm', () => {
  //             this.setState({ weaCrmLoaded: true});
  //         }, () => {
  //             alert("加载客户模块失败，请联系系统管理员！");
  //         });
  //     // }
  // }
  render() {
    const { store } = this.state;
    const { params, hidetop } = store;
    return (
      <div className="crm-sellchance-new-pc">
        {hidetop != 1 && <div className="crm-addremind-form-head">
          <div className="crm-addremind-form-head-dialog" >
            <i className="icon-coms-crm" />
          </div>
          <div className="crm-addremind-form-head-name" >
            {getLabel('82210', '新建提醒') }
          </div>
        </div>}
        <div className="crm-addremind-form-body">
          <AddRemindForm
            ecId={`${this && this.props && this.props.ecId || ''}_AddRemindForm@kg9abq`}
            ref="remindFormRef"
            params={params}// 参数，receiver=11182&receiverspan=许秀军&sellchanceid=15553&sellchancespan=许秀军测试商机购买商机
            onDiaCloseClick={this.onClose}
          />
        </div>

        <div className="crm-addremind-form-foot">
          <div className="footer-btns">
            <button type="button" className="ant-btn ant-btn-primary" onClick={() => { this.refs.remindFormRef.state.store.saveAddRemind(); }}>
              <span>{getLabel('826', '确定')}</span>
            </button>
            <button type="button" className="ant-btn ant-btn-primary" onClick={() => { this.refs.remindFormRef.state.store.resetForm(); }}>
              <span>{getLabel('2022', '重置')}</span>
            </button>
            <button type="button" className="ant-btn ant-btn-ghost" onClick={() => { this.onClose(); }}>
              <span>{getLabel('201', '取消')}</span>
            </button>
          </div>
        </div>
      </div>
    );
  }

    // 弹框关闭事件
    onClose = () => {
      if (parent.getDialog) {
        const dialog = parent.getDialog(window);
        dialog && dialog.close();
      }
    }
}
